package com.wc.alorithm_luogu._思维.DlgtRank;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/11/10 15:09
 * @description
 * https://www.luogu.com.cn/problem/T495064?contestId=127930
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] a = new int[N], b = new int[N];
    static long[] rank = new long[N], f = new long[N];
    static int n, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i] = b[i] = sc.nextInt();
        }
        Arrays.sort(b, 1, n + 1);
        int cnt = 1;
        for (int i = 1; i <= n; i++) {
            if (b[i] != b[i - 1]) rank[cnt++] = b[i];
        }
        for (int i = cnt - 2; i >= 1; i--) {
            if (rank[i] + f[i + 1] * k + k < rank[i + 1]) f[i] = 0;
            else {
                f[i] = (rank[i] + f[i + 1] * k + k - rank[i + 1] + k) / k;

            }
        }
        for (int i = 1; i <= n; i++){
            int l = 1, r = cnt - 1;
            while (l < r){
                int mid = l + r + 1>> 1;
                if (rank[mid] <= a[i]) l = mid;
                else r = mid - 1;
            }
            out.print(f[l] + " ");
        }
        out.println();
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

